package com.quydat.forum.entites;

import java.io.Serializable;
import javax.persistence.*;

import java.util.List;


/**
 * The persistent class for the user database table.
 * 
 */
@Entity
@Table(name = "\"user\"")
@NamedQueries(
{
	@NamedQuery(name=UserEntity.GET_USER_WITH_NAME_PASSWORD, query="select u from User u" +
			" where u.loginName= :loginName and u.password= :password")
})
public class UserEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="USER_ID_GENERATOR", sequenceName="USER_SEQ", allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="USER_ID_GENERATOR")
	
	@Column(unique=true, nullable=false)
	
	private Integer id;

	@Column(name="login_name", nullable=false, length=2147483647)
	private String loginName;

	@Column(nullable=false, length=2147483647)
	private String password;
/**
 * named query to get user who hat login_name and password
 */
	public static final String GET_USER_WITH_NAME_PASSWORD="UserEntity.getUserWithNamePassword";
	//bi-directional many-to-one association to PostEntity
	@OneToMany(mappedBy="user")
	private List<PostEntity> posts;

	//bi-directional many-to-one association to UserGroupEntity
    @ManyToOne
	@JoinColumn(name="user_group_id", nullable=false)
	private UserGroupEntity userGroup;

    public UserEntity() {
    }

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getLoginName() {
		return this.loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public List<PostEntity> getPosts() {
		return this.posts;
	}

	public void setPosts(List<PostEntity> posts) {
		this.posts = posts;
	}
	
	public UserGroupEntity getUserGroup() {
		return this.userGroup;
	}

	public void setUserGroup(UserGroupEntity userGroup) {
		this.userGroup = userGroup;
	}
	
}